import sys

def print_usage():
    print('gen_empty_word_entry.py <out_file> <start_id> <count> [TYPE]')

if __name__ == '__main__':
    if len(sys.argv) != 4 and len(sys.argv) != 5:
        print_usage()
        exit(1)
    start_id = int(sys.argv[2])
    id_count = int(sys.argv[3])
    if id_count <= 0:
        print('"count" must >= 0')
        exit(1)
    end_id = start_id + id_count - 1
    type_str = ''
    if len(sys.argv) == 5:
        type_str = sys.argv[4]
    ids_str = ''
    output_lines = ['\n']
    # sent类型只需w和m
    if type_str == 'SENT':
        for i in range(start_id, end_id + 1):
            output_lines.append('%d`w=`m=`t=SENT\n'%(i))
            ids_str = ids_str + str(i) + ','    
    else:
        for i in range(start_id, end_id + 1):
            output_lines.append('%d`w=`g=`pn=`m=`t=%s\n'%(i, type_str))
            ids_str = ids_str + str(i) + ','
        
    output_lines.append('\n# ,"":["",[%s]]\n'%(ids_str[:-1]))

    with open(sys.argv[1], 'a', encoding='UTF-8') as f:
        f.writelines(output_lines)
    
